//
//  SeePasswordTool.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2024/10/28.
//  Copyright © 2024 zwb. All rights reserved.
//

import UIKit

class SeePasswordTool: UIButton {
    var relevanceField:UITextField?
    var isShowPwd = false
    override init(frame: CGRect) {
        super.init(frame: frame)
    
            self.setImage(#imageLiteral(resourceName: "view_close"), for: UIControl.State())
        self.addTouchUpInSideAction { _ in
 
            if self.relevanceField.isSome {
                self.relevanceField!.isSecureTextEntry = self.isShowPwd
                if self.isShowPwd {
                    self.setImage(#imageLiteral(resourceName: "view_close"), for: UIControl.State())
                } else {
                    self.setImage(#imageLiteral(resourceName: "view_see"), for: UIControl.State())
                }
            } else {
                KSToast("未配置关联field")
            }
            self.isShowPwd = !self.isShowPwd
            
        }
    }
    
    
    
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
